home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / LiveFastStartServer / Open Transport 1.3 / Includes / CIncludes / OpenTptClient.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-30  |  24.0 KB  |  704 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OpenTptClient.h
  3.  
  4.     Contains:    headers for client development
  5.  
  6.     Copyright:    © 1993-1996 by Apple Computer, Inc. and Mentat Inc., all rights reserved.
  7.  
  8.  
  9. */
  10.  
  11. #ifndef __OPENTPTCLIENT__
  12. #define __OPENTPTCLIENT__
  13.  
  14. #ifndef __OPENTPTCOMMON__
  15. #include <OpenTptCommon.h>
  16. #endif    
  17. #ifndef __STROPTS__
  18. #include <stropts.h>
  19. #endif
  20.  
  21. #if defined(__MWERKS__) && GENERATING68K
  22. #pragma pointers_in_D0
  23. #endif
  24.  
  25. #if PRAGMA_ALIGN_SUPPORTED
  26. #pragma options align=mac68k
  27. #endif
  28. #if PRAGMA_IMPORT_SUPPORTED
  29. #pragma import on
  30. #endif
  31.  
  32. /*******************************************************************************
  33. ** Allocation functions
  34. ********************************************************************************/
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40.     extern void*    OTAllocSharedClientMem(size_t);
  41.     extern void        OTFreeSharedClientMem(void*);
  42.  
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46.  
  47. /*******************************************************************************
  48. ** STREAM APIs and Structures
  49. ********************************************************************************/
  50.  
  51.     typedef void*                StreamRef;
  52.  
  53.     #define kOTInvalidStreamRef        ((StreamRef)0)
  54.     
  55. /*    -------------------------------------------------------------------------
  56.     Autopush information
  57.     
  58.     The autopush functionality for Open Transport is based on the names of
  59.     devices and modules, rather than on the major number information like 
  60.     SVR4.  This is so that autopush information can be set up for modules
  61.     that are not yet loaded.
  62.     ------------------------------------------------------------------------- */
  63.     /*
  64.      * This is the name of the stream module you open and send the 
  65.      * IOCTL modules to.
  66.      */
  67.     #define kSADModuleName    "sad"
  68.     
  69.     enum
  70.     {
  71.         kOTAutopushMax    = 8,
  72.         
  73.         I_SAD_SAP        = MIOC_CMD(MIOC_SAD, 1),    /* Set autopush information        */
  74.         I_SAD_GAP        = MIOC_CMD(MIOC_SAD, 2),    /* Get autopush information        */
  75.         I_SAD_VML        = MIOC_CMD(MIOC_SAD, 3)        /* Validate a list of modules     */
  76.                                                     /* (uses str_list structure        */
  77.                                                     /*    in stropts.h)                */
  78.     };
  79.  
  80.     struct OTAutopushInfo            /* Ioctl structure used for SAD_SAP and SAD_GAP commands */
  81.     {
  82.         uint_t            sap_cmd;
  83.         char            sap_device_name[kMaxModuleNameSize];
  84.         long            sap_minor;
  85.         long            sap_lastminor;
  86.         long            sap_npush;
  87.         char            sap_list[kOTAutopushMax][kMaxModuleNameSize];
  88.     };
  89.     
  90.     typedef struct OTAutopushInfo    OTAutopushInfo;
  91.     
  92.     /*
  93.      * Command values for sap_cmd
  94.      */
  95.     
  96.     enum
  97.     {
  98.         kSAP_ONE            = 1,    /* Configure a single minor device            */
  99.         kSAP_RANGE            = 2,    /* Configure a range of minor devices        */
  100.         kSAP_ALL            = 3,    /* Configure all minor devices                */
  101.         kSAP_CLEAR            = 4        /* Clear autopush information                */
  102.     };
  103.     
  104. /*    -------------------------------------------------------------------------
  105.     PollRef structure
  106.     
  107.     This is used with the OTStreamPoll function
  108.     ------------------------------------------------------------------------- */
  109.  
  110.     struct PollRef 
  111.     {
  112.         int_t         filler;
  113.         short        events;
  114.         short        revents;
  115.         StreamRef     ref;
  116.     };
  117.     
  118.     typedef struct PollRef    PollRef;
  119.  
  120. /*    -------------------------------------------------------------------------
  121.     OTReadInfo structure
  122.     
  123.     This is used with the various functions that read and peek at the 
  124.     streamhead.
  125.     ------------------------------------------------------------------------- */
  126.  
  127.     struct OTReadInfo
  128.     {
  129.         UInt32        fType;
  130.         OTCommand    fCommand;
  131.         UInt32        fFiller;    /* For compatibility with OT 1.0 and 1.1 */
  132.         size_t        fBytes;
  133.         OSStatus    fError;
  134.     };
  135.  
  136.     typedef struct OTReadInfo    OTReadInfo;
  137.     
  138.     /*    -------------------------------------------------------------------------
  139.         Used in the fType field of OTReadInfo for functions
  140.         ------------------------------------------------------------------------- */
  141.  
  142.     enum
  143.     {
  144.         kOTNoMessagesAvailable    = 0xffffffffU,
  145.             // Matches any message on requests, and indicates no
  146.             // peeked message available on return.
  147.         kOTAnyMsgType            = 0xfffffffeU,
  148.             // Blows away any message not of type M_PROTO, M_PCPROTO or M_DATA
  149.             // No match on OTCommand field
  150.         kOTDataMsgTypes            = 0xfffffffcU,
  151.             // Returns only M_PROTO or M_PCPROTO messages. 
  152.             // Matches on OTCommand field, with special match for request = T_DATA_IND
  153.             // and msg = T_EXDATA_IND.  Also, returns an M_DATA if T_DATA_IND or
  154.             // T_UNITDATA_IND (or 0) is requested. Blows away all other message types.
  155.             // If OTCommand is 0, matches any command.
  156.         kOTMProtoMsgTypes        = 0xfffffffbU,
  157.             // Exactly like kOTMProtoMsgTypes, except M_DATAs are also blown away
  158.         kOTOnlyMProtoMsgTypes    = 0xfffffffaU
  159.     };
  160.     
  161.     /*    -------------------------------------------------------------------------
  162.         Use in PutCommand, PutData, and PutWriteData
  163.         These equates must not conflict with any of the other putmsg flags
  164.         MSG_ANY, MSG_BAND, MSG_HIPRI, or RS_HIPRI
  165.         ------------------------------------------------------------------------- */
  166.     
  167.     enum
  168.     {
  169.         RS_EXDATA        = 0x20,
  170.         RS_ALLOWAGAIN    = 0x40,
  171.         RS_DELIMITMSG    = 0x80
  172.     };
  173.  
  174. /*    -------------------------------------------------------------------------
  175.     The functions 
  176.     ------------------------------------------------------------------------- */
  177.  
  178. #ifdef __cplusplus
  179. extern "C" {
  180. #endif
  181.  
  182.     extern pascal StreamRef        OTStreamOpen(const char* name, OTOpenFlags, OSStatus*);
  183.     extern pascal OSStatus        OTAsyncStreamOpen(const char* name, OTOpenFlags,
  184.                                                   OTNotifyProcPtr, void* contextPtr);
  185.     extern pascal StreamRef        OTCreateStream(OTConfiguration* cfig, OTOpenFlags, OSStatus*);
  186.     extern pascal OSStatus        OTAsyncCreateStream(OTConfiguration* cfig, OTOpenFlags,
  187.                                                     OTNotifyProcPtr, void* contextPtr);
  188.     extern pascal OTResult        OTStreamPoll(PollRef* fds, UInt32 nfds, OTTimeout timeout);
  189.     extern pascal OTResult        OTAsyncStreamPoll(PollRef* fds, UInt32 nfds, OTTimeout timeout,
  190.                                                   OTNotifyProcPtr, void* contextPtr);
  191.     
  192.     extern pascal OSStatus        OTStreamClose(StreamRef);
  193.     extern pascal OTResult        OTStreamRead(StreamRef, void* buf, size_t len);
  194.     extern pascal OTResult        OTStreamWrite(StreamRef, void* buf, size_t len);
  195.     extern pascal OTResult        OTStreamIoctl(StreamRef, UInt32 type, void* data);
  196.     extern pascal OTResult        OTStreamPipe(StreamRef*);
  197.     extern pascal void            OTStreamSetBlocking(StreamRef);
  198.     extern pascal void            OTStreamSetNonBlocking(StreamRef);
  199.     extern pascal Boolean        OTStreamIsBlocking(StreamRef);
  200.     extern pascal void            OTStreamSetSynchronous(StreamRef);
  201.     extern pascal void            OTStreamSetAsynchronous(StreamRef);
  202.     extern pascal Boolean        OTStreamIsSynchronous(StreamRef);
  203.     extern pascal OTResult        OTStreamGetMessage(StreamRef, struct strbuf* ctlbuf,
  204.                                                    struct strbuf* databuf, OTFlags*);
  205.     extern pascal OTResult        OTStreamGetPriorityMessage(StreamRef, struct strbuf* ctlbuf,
  206.                                                            struct strbuf* databuf, OTBand*, OTFlags*);
  207.     extern pascal OSStatus        OTStreamPutMessage(StreamRef, const struct strbuf* ctlbuf,
  208.                                      const struct strbuf* databuf, OTFlags flags);
  209.     extern pascal OSStatus        OTStreamPutPriorityMessage(StreamRef, const struct strbuf* ctlbuf,
  210.                                                            const struct strbuf* databuf, OTBand, OTFlags);
  211.     extern pascal OSStatus        OTStreamInstallNotifier(StreamRef, OTNotifyProcPtr, void* contextPtr);
  212.     extern pascal void            OTStreamRemoveNotifier(StreamRef);
  213.     extern pascal void            OTStreamSetControlMask(StreamRef ref, UInt32 mask, Boolean setClear);
  214.     extern pascal OSStatus        OTStreamUseSyncIdleEvents(StreamRef, Boolean useEvents);
  215.     /*
  216.      * Opening endpoints and mappers on a Stream - these calls are synchronous, and may
  217.      * only be used at System Task time. Once the stream has been installed into a provider
  218.      * or endpoint, you should not continue to use STREAMS APIs on it
  219.      */
  220.     extern pascal ProviderRef    OTOpenProviderOnStream(StreamRef, OSStatus*);
  221.     extern pascal EndpointRef    OTOpenEndpointOnStream(StreamRef, OSStatus*);
  222.     /*
  223.      * Some functions that should only be used if you really know what you're doing.
  224.      */
  225.     extern pascal StreamRef        OTRemoveStreamFromProvider(ProviderRef);
  226.     extern pascal OSStatus        OTPeekMessage(StreamRef, OTReadInfo*);
  227.     extern pascal OTBuffer*        OTReadMessage(StreamRef, OTReadInfo*);
  228.     extern pascal void            OTPutBackBuffer(StreamRef, OTBuffer*);
  229.     extern pascal void            OTPutBackPartialBuffer(StreamRef, OTBufferInfo*, OTBuffer*);
  230.  
  231. #ifdef __cplusplus
  232. }
  233. #endif
  234.  
  235. /*******************************************************************************
  236. ** Port functions
  237. ********************************************************************************/
  238.         
  239. #ifdef __cplusplus
  240. extern "C" {
  241. #endif
  242.         //
  243.         // Returns a buffer containing all of the clients that refused to yield the port.
  244.         // "size" is the total number of bytes @ buffer, including the fNumClients field.
  245.         //
  246.     extern OSStatus    OTYieldPortRequest(ProviderRef, OTPortRef, OTClientList* buffer, size_t size);
  247.         //
  248.         // Send a notification to all Open Transport registered clients
  249.         //
  250.     extern void        OTNotifyAllClients(OTEventCode, OTResult, void* cookie);
  251.         //
  252.         // Determine if "child" is a child port of "parent"
  253.         //
  254.     extern Boolean    OTIsDependentPort(OTPortRef parent, OTPortRef child);
  255.  
  256. #ifdef __cplusplus
  257. }
  258. #endif
  259.  
  260. /*******************************************************************************
  261. ** Timer functions
  262. ********************************************************************************/
  263.  
  264. #ifdef __cplusplus
  265. extern "C" {
  266. #endif
  267.  
  268.     extern pascal long        OTCreateTimerTask(OTProcessProcPtr proc, void* arg);
  269.     extern pascal Boolean    OTCancelTimerTask(long timerTask);
  270.     extern pascal void        OTDestroyTimerTask(long timerTask);
  271.     extern pascal Boolean    OTScheduleTimerTask(long timerTask, OTTimeout milliSeconds);
  272.  
  273. #ifdef __cplusplus
  274. }
  275. #endif
  276.  
  277. /*******************************************************************************
  278. ** Miscellaneous helpful functions
  279. ********************************************************************************/
  280.  
  281. #ifdef __cplusplus
  282. extern "C" {
  283. #endif
  284.  
  285.     extern Boolean            StoreIntoNetbuf(TNetbuf*, void*, long);
  286.     extern Boolean            StoreMsgIntoNetbuf(TNetbuf*, OTBuffer* buf);
  287.     extern void                OTReleaseBuffer(OTBuffer*);
  288.     extern size_t            OTBufferDataSize(OTBuffer*);
  289.     
  290.     extern Boolean            OTReadBuffer(OTBufferInfo*, void*, size_t*);
  291.  
  292. #ifdef __cplusplus
  293. }
  294. #endif
  295.  
  296. /*******************************************************************************
  297. ** OTConfiguration
  298. **
  299. ** This structure is used to describe a configuration.  
  300. ********************************************************************************/
  301.  
  302.     typedef struct OTConfiguration    OTConfiguration;
  303.         
  304. #ifdef __cplusplus
  305. extern "C" {
  306. #endif
  307.  
  308.     /*
  309.      * Manipulating a configuration
  310.      */
  311.     extern OTConfiguration*    OTCfigNewConfiguration(const char* path);
  312.     extern void                OTCfigDeleteConfiguration(OTConfiguration*);
  313.     extern OTConfiguration*    OTCfigCloneConfiguration(OTConfiguration*);
  314.     extern OTConfiguration*    OTCfigPushNewSingleChild(OTConfiguration*, const char* path, OSStatus*);
  315.     extern OTConfiguration*    OTCfigPushParent(OTConfiguration*, const char* path, OSStatus*);
  316.     extern OTConfiguration*    OTCfigPushChild(OTConfiguration*, size_t index, const char* path, OSStatus*);
  317.     extern OSStatus            OTCfigPopChild(OTConfiguration*, size_t index);
  318.     extern OTConfiguration*    OTCfigGetChild(OTConfiguration*, size_t index);
  319.     extern OSStatus            OTCfigSetPath(OTConfiguration*, const char* path);
  320.     extern OTConfiguration*    OTCfigNewChild(OTConfiguration*, const char* path, OSStatus*);
  321.     extern OSStatus            OTCfigAddChild(OTConfiguration*, OTConfiguration* child);
  322.     extern OTConfiguration*    OTCfigRemoveChild(OTConfiguration*, size_t index);
  323.     extern void                OTCfigSetPortRef(OTConfiguration*, OTPortRef);
  324.     extern void                OTCfigChangeProviderName(OTConfiguration*, const char* name);
  325.     /*
  326.      * Query a configuration
  327.      */
  328.     extern UInt16            OTCfigNumberOfChildren(OTConfiguration*);
  329.     extern OTConfiguration*    OTCfigGetParent(OTConfiguration*);
  330.     extern TNetbuf*            OTCfigGetOptionNetbuf(OTConfiguration*);
  331.     extern OTPortRef        OTCfigGetPortRef(OTConfiguration*);
  332.     extern UInt32            OTCfigGetInstallFlags(OTConfiguration*);
  333.     extern const char*        OTCfigGetProviderName(OTConfiguration*);
  334.     extern Boolean            OTCfigIsPort(OTConfiguration*);
  335.  
  336. #ifdef __cplusplus
  337. }
  338. #endif
  339.  
  340. /*******************************************************************************
  341. ** Configurator functions
  342. ********************************************************************************/
  343.  
  344. #ifdef __cplusplus
  345.     class TOTConfigurator;
  346. #else
  347.     typedef struct TOTConfigurator    TOTConfigurator;
  348. #endif
  349.  
  350.     //
  351.     // Typedef for the OTCanConfigure function, and the enum for which pass we're doing.
  352.     // The first (kOTSpecificConfigPass) is to give configurators a shot at the configuration
  353.     // before we start allowing the generic configurators to get into the act.
  354.     //
  355.     enum
  356.     {
  357.         kOTSpecificConfigPass = 0, kOTGenericConfigPass = 1
  358.     };
  359.     
  360. #ifdef __cplusplus
  361. extern "C" {
  362. #endif
  363.  
  364.     typedef Boolean            (*OTCanConfigureProcPtr)(OTConfiguration*, UInt32 pass);
  365.     //
  366.     // Typedef for the function to create and return a configurator object
  367.     //
  368.     typedef OSStatus        (*OTCreateConfiguratorProcPtr)(TOTConfigurator**);
  369.     //
  370.     // Typedef for the OTSetupConfigurator function that your configurator library must export.
  371.     // The enum is for the type of configurator that it is.
  372.     //
  373.     enum
  374.     {
  375.         kOTDefaultConfigurator = 0, kOTProtocolFamilyConfigurator, kOTLinkDriverConfigurator
  376.     };
  377.     typedef OSStatus        (*OTSetupConfiguratorProcPtr)(OTCanConfigureProcPtr*,
  378.                                                           OTCreateConfiguratorProcPtr*,
  379.                                                           UInt8* type);
  380.     
  381.     typedef void (*OTCFHandleSystemEventProcPtr)(TOTConfigurator*, OTEventCode, OTResult, void*);
  382.     typedef OSStatus (*OTCFConfigureProcPtr)(TOTConfigurator*, OTConfiguration*);
  383.     typedef OSStatus (*OTCFCreateStreamProcPtr)(TOTConfigurator*, OTConfiguration*, OTOpenFlags,
  384.                                                 OTNotifyProcPtr, void*);
  385.     
  386.     //
  387.     // Determine if this instance of your configurator is the "master"
  388.     // (the one that can create and destroy control streams)
  389.     //
  390.     extern Boolean            OTIsMasterConfigurator(TOTConfigurator*);
  391.     //
  392.     // Get back the userData you passed in to OTNewConfigurator
  393.     //
  394.     extern void*            OTGetConfiguratorUserData(TOTConfigurator*);
  395.     //
  396.     // Create a configurator object for use by Open Transport
  397.     //
  398.     extern TOTConfigurator*    OTNewConfigurator(void* userData, OTCFConfigureProcPtr, OTCFCreateStreamProcPtr,
  399.                                               OTCFHandleSystemEventProcPtr);
  400.     //
  401.     // Delete a configurator object created by OTNewConfigurator
  402.     //
  403.     extern void                OTDeleteConfigurator(TOTConfigurator*);
  404.     //
  405.     // A utility function to send notifications to the user - it takes care of calls
  406.     // from deferred tasks
  407.     //
  408.     typedef struct FSSpec    FSSpec;
  409.     extern OSStatus            OTNotifyUser(FSSpec* theFile, SInt32 rsrcID, size_t index,
  410.                                          char* parm1, char* parm2);
  411.     //
  412.     // Call when the configurator unloads from memory
  413.     //
  414.     extern void                OTConfiguratorUnloaded(TOTConfigurator*);
  415.     //
  416.     // Call to create your control stream if you're not the master
  417.     // configurator.  You can also use the state machine function
  418.     // OTSMCreateControlStream(OTStateMachine*, OTConfiguration*, TOTConfigurator*).
  419.     //
  420.     extern OSStatus            OTCreateControlStream(OTConfiguration*,TOTConfigurator*,
  421.                                                   OTNotifyProcPtr, void*);
  422.     //
  423.     // A helpful function for the configurators to
  424.     // be able to recursively configure the children.
  425.     //
  426.     extern OSStatus            OTConfigureChildren(OTConfiguration*);
  427.  
  428.     extern UInt32            OTNewControlMask(void);
  429.             //
  430.             // %%% These 2 APIs is going away
  431.             //
  432.     extern void                OTCloseProvidersByUseCount(SInt32* useCount, OTResult reason, boolean_p doneDeal);
  433.     extern void                OTCloseProvidersByPortRef(OTPortRef ref, OTResult reason, boolean_p doneDeal);
  434.             //
  435.             // These are the "real" APIs
  436.             //
  437.     extern void                OTCloseProviderByStream(StreamRef ref, OTResult reason, boolean_p doneDeal);
  438.     extern void                OTCloseMatchingProviders(UInt32 mask, OTPortRef port, OTResult reason, boolean_p doneDeal);
  439.  
  440. #ifdef __cplusplus
  441. }
  442. #endif
  443.     
  444. /*    -------------------------------------------------------------------------
  445.     The kOTConfiguratorInterfaceID define is what you need to add to your
  446.     export file for the "interfaceID = " clause to export a configurator
  447.     for ASLM
  448.     ------------------------------------------------------------------------- */
  449.     #define kOTConfiguratorInterfaceID    kOTClientPrefix "cfigMkr"
  450.     
  451. /*******************************************************************************
  452. ** OTStateMachine
  453. **
  454. ** This utility set allows you to write an asynchronous chain of code that looks 
  455. ** somewhat like it is synchronous.  This is primarily used for plumbing 
  456. ** streams asynchronously, especially in configurators
  457. ********************************************************************************/
  458.  
  459.     typedef struct OTStateMachine    OTStateMachine;
  460.  
  461.     typedef UInt32    UInt16_p;
  462.  
  463.     #define kOTSMBufferSize(callDepth)        (80 + (callDepth * 8))
  464.  
  465. #ifdef __cplusplus
  466. extern "C" {
  467. #endif
  468.  
  469.     typedef pascal void (*OTStateProcPtr)(OTStateMachine*);
  470.     typedef void (*OTSMCompleteProcPtr)(void* contextPtr);
  471.  
  472.     /*
  473.      * For structSize, pass the size of your structure that you want associated with
  474.      * the state machine.  It can always be obtained by calling OTSMGetClientData().
  475.      * For bufSize, use the kOTSMBufferSize macro, plus the size of your structure
  476.      * to create a buffer on the stack. For synchronous calls, the stack buffer will
  477.      * be used (unless you pass in NULL).  The callDepth is the depth level of nested
  478.      * calls using OTSMCallStateProc.
  479.      */
  480.     extern OTStateMachine*    OTCreateStateMachine(void*, size_t bufSize, size_t structSize,
  481.                                                  OTNotifyProcPtr, void* contextPtr);
  482.     extern void                OTDestroyStateMachine(OTStateMachine*);
  483.     extern Boolean            OTSMCallStateProc(OTStateMachine*, OTStateProcPtr proc, UInt16_p state);
  484.     extern UInt16            OTSMGetState(OTStateMachine*);
  485.     extern void                OTSMSetState(OTStateMachine*, UInt16_p);
  486.                     // Fill out the fCookie, fCode, and fResult fields before calling!
  487.     extern void                OTSMComplete(OTStateMachine*);
  488.     extern void                OTSMPopCallback(OTStateMachine*);
  489.     extern Boolean            OTSMWaitForComplete(OTStateMachine*);
  490.     extern Boolean            OTSMCreateStream(OTStateMachine*, OTConfiguration*, OTOpenFlags);
  491.     extern Boolean            OTSMOpenStream(OTStateMachine*, const char*, OTOpenFlags flags);
  492.     extern Boolean            OTSMIoctl(OTStateMachine*, StreamRef, UInt32, long);
  493.     extern Boolean            OTSMPutMessage(OTStateMachine*, StreamRef, struct strbuf*, struct strbuf*, OTFlags);
  494.     extern Boolean            OTSMGetMessage(OTStateMachine*, StreamRef, struct strbuf*, struct strbuf*, OTFlags*);
  495.     extern OSStatus            OTSMReturnToCaller(OTStateMachine*);
  496.     extern void*            OTSMGetClientData(OTStateMachine*);
  497.     extern void                OTSMInstallCompletionProc(OTStateMachine*, OTSMCompleteProcPtr, void* contextPtr);
  498.     extern Boolean            OTSMCreateControlStream(OTStateMachine*, OTConfiguration*, TOTConfigurator*);
  499.  
  500. #ifdef __cplusplus
  501.     }
  502. #endif
  503.     
  504.     struct OTStateMachine
  505.     {
  506.     #if GENERATINGPOWERPC
  507.                 UInt8                fData[12];
  508.     #else
  509.                 UInt8                fData[8];
  510.     #endif
  511.                 void*                fCookie;
  512.                 OTEventCode            fCode;
  513.                 OTResult            fResult;
  514.                 
  515. #ifdef __cplusplus
  516.                     void*        GetClientData()
  517.                                 { return OTSMGetClientData(this); }
  518.             //
  519.             // Call an OTStateProcPtr procedure.
  520.             //
  521.                     Boolean        CallStateProc(OTStateProcPtr proc, UInt16_p state = 0)
  522.                                 { return OTSMCallStateProc(this, proc, state); }
  523.             //
  524.             // Get and Set the current state
  525.             //
  526.                     UInt16        GetState()
  527.                                 { return OTSMGetState(this); }
  528.                     void        SetState(UInt16_p state)
  529.                                 { OTSMSetState(this, state); }
  530.             //
  531.             // These calls complete to the client without changing who to call back
  532.             //
  533.                     void        Complete()
  534.                                 { OTSMComplete(this); }
  535.                     void        Complete(OTResult);
  536.                     void        Complete(OTResult, OTEventCode, void*);
  537.             //
  538.             // These calls complete to the client by popping the current callback
  539.             //
  540.                     void        CompleteToClient();
  541.                     void        CompleteToClient(OTResult);
  542.                     void        CompleteToClient(OTResult, OTEventCode, void*);
  543.             //
  544.             // This call pops the current callback off the callback stack
  545.             //
  546.                     void        PopCallback()
  547.                                 { OTSMPopCallback(this); }
  548.                                 
  549.                     Boolean        CreateStream(OTConfiguration* cfig, OTOpenFlags flags)
  550.                                 { return OTSMCreateStream(this, cfig, flags); }
  551.                     Boolean        OpenStream(const char* name, OTOpenFlags flags)
  552.                                 { return OTSMOpenStream(this, name, flags); }
  553.     
  554.                     Boolean        SendIoctl(StreamRef ref, UInt32 type, void* data)
  555.                                 { return OTSMIoctl(this, ref, type, (long)data); }
  556.                     Boolean        SendIoctl(StreamRef ref, UInt32 type, long data)
  557.                                 { return OTSMIoctl(this, ref, type, data); }
  558.                     Boolean        PutMessage(StreamRef ref, struct strbuf* ctl, struct strbuf* data, OTFlags flags)
  559.                                 { return OTSMPutMessage(this, ref, ctl, data, flags); }
  560.                     Boolean        GetMessage(StreamRef ref, struct strbuf* ctl, struct strbuf* data, OTFlags* flagPtr)
  561.                                 { return OTSMGetMessage(this, ref, ctl, data, flagPtr); }
  562.     
  563.                     OSStatus    ReturnToCaller()
  564.                                 { return OTSMReturnToCaller(this); }
  565. #endif
  566.     };
  567.     
  568. #ifdef __cplusplus
  569.         //
  570.         // Other inline methods for OTStateMachine
  571.         //
  572.         inline void OTStateMachine::Complete(OTResult result, OTEventCode code,
  573.                                                 void* cookie)
  574.         {
  575.             fCookie    = cookie;
  576.             fCode    = code;
  577.             fResult    = result;
  578.             Complete();
  579.         }
  580.     
  581.         inline void OTStateMachine::Complete(OTResult result)
  582.         {
  583.             fResult    = result;
  584.             Complete();
  585.         }
  586.     
  587.         inline void OTStateMachine::CompleteToClient()
  588.         {
  589.             PopCallback();
  590.             Complete();
  591.         }
  592.         
  593.         inline void OTStateMachine::CompleteToClient(OTResult result, OTEventCode code,
  594.                                                      void* cookie)
  595.         {
  596.             fCookie    = cookie;
  597.             fCode    = code;
  598.             fResult    = result;
  599.             CompleteToClient();
  600.         }
  601.     
  602.         inline void OTStateMachine::CompleteToClient(OTResult result)
  603.         {
  604.             fResult    = result;
  605.             CompleteToClient();
  606.         }
  607.         
  608. #endif    /* __cplusplus    */
  609.  
  610. /*******************************************************************************
  611. ** A few C++ objects for C++ fans
  612. ********************************************************************************/
  613.  
  614. #ifdef __cplusplus
  615.  
  616.     class OTConfiguration
  617.     {
  618.         public:
  619.                     OTConfiguration*    Clone()
  620.                                         { return OTCfigCloneConfiguration(this); }
  621.                 //
  622.                 // The Path for PushChild and PushParent must be a single module
  623.                 //
  624.                     OTConfiguration*    PushChild(const char* path, OSStatus* errPtr)
  625.                                         { return OTCfigPushNewSingleChild(this, path, errPtr); }
  626.                     OTConfiguration*    PushParent(const char* path, OSStatus* errPtr)
  627.                                         { return OTCfigPushParent(this, path, errPtr); }
  628.                     OTConfiguration*    PushNthChild(size_t index, const char* path,
  629.                                                      OSStatus* errPtr)
  630.                                         { return OTCfigPushChild(this, index, path, errPtr); }
  631.                     OSStatus            PopChild(size_t index)
  632.                                         { return OTCfigPopChild(this, index); }
  633.  
  634.                     OTConfiguration*    GetChild(size_t index = 0)
  635.                                         { return OTCfigGetChild(this, index); }
  636.                     OTConfiguration*    GetParent()
  637.                                         { return OTCfigGetParent(this); }
  638.             
  639.                     OSStatus            AddChild(OTConfiguration* child)
  640.                                         { return OTCfigAddChild(this, child); }
  641.                     
  642.                     OTConfiguration*    NewChild(const char* path, OSStatus* errPtr)
  643.                                         { return OTCfigNewChild(this, path, errPtr); }
  644.         
  645.                     OSStatus            SetPath(const char* path)
  646.                                         { return OTCfigSetPath(this, path); }
  647.             
  648.                     Boolean                HasOptions()
  649.                                         { return OTCfigGetOptionNetbuf(this)->len != 0; }
  650.     };
  651.  
  652. /*    -------------------------------------------------------------------------
  653.     Class TOTConfigurator
  654.  
  655.     This class is subclassed to do configuration for a protocol or protocol stack.
  656.     Of course, you can also use OTNewConfigurator to do it from "C".
  657.     
  658.     If you subclass it using C++, you MUST have a UInt32 field as the first
  659.     field of your object that you do not touch or use.
  660.     ------------------------------------------------------------------------- */
  661.  
  662.     #if GENERATING68K && !defined(__SC__) && !defined(THINK_CPLUS)
  663.     class TOTConfigurator : public SingleObject
  664. #else
  665.     class TOTConfigurator
  666. #endif
  667.     {
  668.     #if defined(__SC__) || defined(THINK_CPLUS) || defined(__MRC__)
  669.         private:
  670.             virtual        void DummyVirtualFunction();
  671.     #endif
  672.                 
  673.         public:
  674.                 void*            operator new(size_t size)
  675.                                 { return OTAllocSharedClientMem(size); }
  676.                 void            operator delete(void* mem)
  677.                                 { OTFreeSharedClientMem(mem); };
  678.                                 
  679.                                 _MDECL TOTConfigurator();
  680.             virtual                ~ _MDECL TOTConfigurator();
  681.     
  682.             virtual void        _MDECL HandleSystemEvent(OTEventCode event, OTResult result,
  683.                                                          void* cookie)                        = 0;
  684.             
  685.             virtual OSStatus    _MDECL Configure(OTConfiguration*)                            = 0;
  686.             virtual OSStatus    _MDECL CreateStream(OTConfiguration*, OTOpenFlags,
  687.                                                      OTNotifyProcPtr, void* contextPtr)        = 0;
  688.     };
  689.  
  690. #endif __cplusplus
  691.  
  692. #if defined(__MWERKS__) && GENERATING68K
  693. #pragma pointers_in_A0
  694. #endif
  695.  
  696. #if PRAGMA_ALIGN_SUPPORTED
  697. #pragma options align=reset
  698. #endif
  699. #if PRAGMA_IMPORT_SUPPORTED
  700. #pragma import off
  701. #endif
  702.  
  703. #endif    /* __OPENTPTCLIENT__ */
  704.